/*    */ package com.cr.framework.interceptor;
/*    */ 
/*    */ import com.cr.common.annotation.RepeatSubmit;
/*    */ import com.cr.common.core.domain.AjaxResult;
/*    */ import com.cr.common.json.JSON;
/*    */ import com.cr.common.utils.ServletUtils;
/*    */ import java.lang.reflect.Method;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import org.springframework.stereotype.Component;
/*    */ import org.springframework.web.method.HandlerMethod;
/*    */ import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
/*    */ 
/*    */ @Component
/*    */ public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter {
/*    */   public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
/* 25 */     if (handler instanceof HandlerMethod) {
/* 27 */       HandlerMethod handlerMethod = (HandlerMethod)handler;
/* 28 */       Method method = handlerMethod.getMethod();
/* 29 */       RepeatSubmit annotation = method.<RepeatSubmit>getAnnotation(RepeatSubmit.class);
/* 30 */       if (annotation != null)
/* 32 */         if (isRepeatSubmit(request)) {
/* 34 */           AjaxResult ajaxResult = AjaxResult.error("不允许重复提交，请稍后再试");
/* 35 */           ServletUtils.renderString(response, JSON.marshal(ajaxResult));
/* 36 */           return false;
/*    */         }  
/* 39 */       return true;
/*    */     } 
/* 43 */     return super.preHandle(request, response, handler);
/*    */   }
/*    */   
/*    */   public abstract boolean isRepeatSubmit(HttpServletRequest paramHttpServletRequest) throws Exception;
/*    */ }


/* Location:              D:\tmp\creditorRights-admin\BOOT-INF\lib\creditorRights-framework-4.7.0.jar!\com\cr\framework\interceptor\RepeatSubmitInterceptor.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */